local skill = fk.CreateSkill{
  name = "tea__zaide",
}
---@type ActiveSkillSpec
local zaide = {
  anim_type = "drawcard",
  min_card_num = 1,
  card_filter = function (self, player, to_select, selected)
    if #selected == 0 then
      return true
    elseif #selected == 1 then
      local c1 = Fk:getCardById(selected[1])
      local c2 = Fk:getCardById(to_select)
      return c1.number == c2.number or c1.suit == c2.suit or c1.type == c2.type
    else
      local c1 = Fk:getCardById(selected[1])
      local c2 = Fk:getCardById(selected[2])
      local c = Fk:getCardById(to_select)
      if c1.number == c2.number then
        return c.number == c1.number
      elseif c1.suit == c2.suit then
        return c.suit == c2.suit
      elseif c1.type == c2.type then
        return c.type == c1.type
      end
    end
  end,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    room:recastCard(effect.cards, player, skill.name)
    local targets = room:askToChoosePlayers(player, {
      targets = room:getOtherPlayers(player),
      skill_name = skill.name,
      min_num = 1,
      max_num = #effect.cards,
      prompt = "#tea__zaide-choose:::"..tostring(#effect.cards),
    })
    if #targets > 0 then
      room:sortByAction(targets)
      for _, p in ipairs(targets) do 
        p:drawCards(1, skill.name)
      end
    end
  end,
}
skill:addEffect("active", zaide)
return skill